package com.beiyou.dto.enums;

import java.util.Arrays;
import java.util.Optional;

/**
 * @author wzby
 * @Date: 2022/10/24 20:24
 */
public enum EnumProductStatus {
    ONLINE(1,"上架","上线后，终端用户就可以在商城看到该类目"),
    OFFLINE (0,"下架","下线后，终端用户就不能商城看到该类目");

    private final Integer code;
    private final String name;
    private final String desc;

    EnumProductStatus(Integer code, String name, String desc) {
        this.code = code;
        this.name = name;
        this.desc = desc;
    }

    public Integer getCode() {
        return code;
    }

    public String getName() {
        return name;
    }

    public String getDesc() {
        return desc;
    }

    public static EnumProductStatus findByCode(Integer code){
        Optional<EnumProductStatus> stream = Arrays.stream(EnumProductStatus.values())
                .filter(p -> p.getCode().equals(code))
                .findFirst();
        return stream.orElse(null);
    }
}

